<div class="content-section introduction">
    <div class="feature-intro">
        <h1>InputMask</h1>
        <p>InputMask component is used to enter input in a certain format such as numeric, date, currency, email and phone.</p>
    </div>
    <app-inputStyleSwitch></app-inputStyleSwitch>
</div>

<div class="content-section implementation">
    <div class="card">
        <div class="p-grid p-fluid">
            <div class="p-col-12 p-md-6 p-lg-4">
                <span>Basic</span>
                <p-inputMask mask="99-999999" [(ngModel)]="val1" placeholder="99-999999"></p-inputMask>
            </div>
            
            <div class="p-col-12 p-md-6 p-lg-4">
                <span>SSN</span>
                <p-inputMask mask="999-99-9999" [(ngModel)]="val2" placeholder="999-99-9999"></p-inputMask>
            </div>
            
            <div class="p-col-12 p-md-6 p-lg-4">
                <span>Date</span>
                <p-inputMask mask="99/99/9999" [(ngModel)]="val3" placeholder="99/99/9999" slotChar="mm/dd/yyyy"></p-inputMask>
            </div>
            
            <div class="p-col-12 p-md-6 p-lg-4">
                <span>Phone</span>
                <p-inputMask mask="(999) 999-9999" [(ngModel)]="val4" placeholder="(999) 999-9999"></p-inputMask>
            </div>
            
            <div class="p-col-12 p-md-6 p-lg-4">
                <span>Phone Ext</span>
                <p-inputMask mask="(999) 999-9999? x99999" [(ngModel)]="val5" placeholder="(999) 999-9999? x99999"></p-inputMask>
            </div>
            
            <div class="p-col-12 p-md-6 p-lg-4">
                <span>Serial Number</span>
                <p-inputMask mask="a*-999-a999" [(ngModel)]="val6" placeholder="a*-999-a999"></p-inputMask>
            </div>
        </div>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;InputMaskModule&#125; from 'primeng/inputmask';
</app-code>

            <h5>Getting Started</h5>
            <p>Component is defined using p-inputMask element with a mask and two-way value binding is enabled with standard ngModel directive.</p>   
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputMask [(ngModel)]="val" mask="99-9999"&gt;&lt;/p-inputMask&gt;
</app-code>

            <h5>Mask</h5>
            <p>Mask format can be a combination of the the following built-in definitions.</p>
            <ul>
                <li>a - Alpha character (defaut: A-Z,a-z)</li>
                <li>9 - Numeric character (0-9)</li>
                <li>* - Alpha numberic character (A-Z,a-z,0-9)</li>
            </ul>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputMask [(ngModel)]="val" mask="a*-999-a999"&gt;&lt;/p-inputMask&gt;
</app-code>
            <p>You can also define your own regex pattern for alpha character</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputMask [(ngModel)]="val" mask="99-aa" characterPattern="[А-Яа-я]"&gt;&lt;/p-inputMask&gt;
</app-code>
            
            <h5>SlotChar</h5>
            <p>Underscore is the default placeholder for a mask and this can be customized using <i>slotChart</i> option.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputMask [(ngModel)]="val" mask="99-9999" slotChar=" "&gt;&lt;/p-inputMask&gt;
</app-code>
            
            <h5>Optional Values</h5>
            <p>If the input does not complete the mask definition, it is cleared by default. Use <i>autoClear</i> property to control this behavior. In addition,
            certain part of a mask can be made optional by using ? symbol where anything after the question mark becomes optional.</p>
                        
            <h5>Model Driven Forms</h5>
            <p>InputMask can be used in a model driven form as well.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputMask formControlName="username" mask="(999) 999-9999? x99999"&gt;&lt;/p-inputMask&gt;
</app-code>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>type</td>
                            <td>string</td>
                            <td>text</td>
                            <td>HTML5 input type</td>
                        </tr>
                        <tr>
                            <td>mask</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Mask pattern.</td>
                        </tr>
                        <tr>
                            <td>slotChar</td>
                            <td>string</td>
                            <td>_</td>
                            <td>Placeholder character in mask, default is underscore.</td>
                        </tr>
                        <tr>
                            <td>autoClear</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Clears the incomplete value on blur.</td>
                        </tr>
                        <tr>
                            <td>unmask</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Defines if ngModel sets the raw unmasked value to bound value or the formatted mask value.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the input field.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the input field.</td>
                        </tr>
                        <tr>
                            <td>placeholder</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Advisory information to display on input.</td>
                        </tr>
                        <tr>
                            <td>size</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Size of the input field.</td>
                        </tr>
                        <tr>
                            <td>maxlength</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Maximum number of character allows in the input field.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Specifies tab order of the element.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element value cannot be altered.</td>
                        </tr>
                        <tr>
                            <td>readonly</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that an input field is read-only.</td>
                        </tr>
                        <tr>
                            <td>name</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the input field.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the component.</td>
                        </tr>
                        <tr>
                            <td>required</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that an input field must be filled out before submitting the form.</td>
                        </tr>
                        <tr>
                            <td>characterPattern</td>
                            <td>string</td>
                            <td>[A-Za-z]</td>
                            <td>Regex pattern for alpha characters</td>
                        </tr>
                        <tr>
                            <td>autoFocus</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, the input gets a focus automatically on load.</td>
                        </tr>
                        <tr>
                            <td>autocomplete</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Used to define a string that autocomplete attribute the current element.</td>
                        </tr>
                        <tr>
                            <td>ariaLabel</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Used to define a string that labels the input element.</td>
                        </tr>
                        <tr>
                            <td>ariaRequired</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Used to indicate that user input is required on an element before a form can be submitted.</td>
                        </tr>
                        <tr>
                            <td>title</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Title text of the input text.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onFocus</td>
                            <td>event: Browser event</td>
                            <td>Callback to invoke when input receives focus.</td>
                        </tr> 
                        <tr>
                            <td>onBlur</td>
                            <td>event: Browser event</td>
                            <td>Callback to invoke when input loses focus.</td>
                        </tr>   
                        <tr>
                            <td>onComplete</td>
                            <td>-</td>
                            <td>Callback to invoke on when user completes the mask pattern.</td>
                        </tr>
                        <tr>
                            <td>onInput</td>
                            <td>-</td>
                            <td>Callback to invoke on when the input field value is altered.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Methods</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>focus</td>
                            <td>-</td>
                            <td>Applies focus to the input.</td>
                        </tr> 
                    </tbody>
                </table>
            </div>

            <h5>Styling</h5>
            <p>Styling is same as <a href="#" [routerLink]="['/inputtext']">inputtext component</a>, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/inputmask" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-inputmask-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;div class="p-grid p-fluid"&gt;
    &lt;div class="p-col-12 p-md-6 p-lg-4"&gt;
        &lt;span&gt;Basic&lt;/span&gt;
        &lt;p-inputMask mask="99-999999" [(ngModel)]="val1" placeholder="99-999999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="p-col-12 p-md-6 p-lg-4"&gt;
        &lt;span&gt;SSN&lt;/span&gt;
        &lt;p-inputMask mask="999-99-9999" [(ngModel)]="val2" placeholder="999-99-9999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="p-col-12 p-md-6 p-lg-4"&gt;
        &lt;span&gt;Date&lt;/span&gt;
        &lt;p-inputMask mask="99/99/9999" [(ngModel)]="val3" placeholder="99/99/9999" slotChar="mm/dd/yyyy"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="p-col-12 p-md-6 p-lg-4"&gt;
        &lt;span&gt;Phone&lt;/span&gt;
        &lt;p-inputMask mask="(999) 999-9999" [(ngModel)]="val4" placeholder="(999) 999-9999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="p-col-12 p-md-6 p-lg-4"&gt;
        &lt;span&gt;Phone Ext&lt;/span&gt;
        &lt;p-inputMask mask="(999) 999-9999? x99999" [(ngModel)]="val5" placeholder="(999) 999-9999? x99999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="p-col-12 p-md-6 p-lg-4"&gt;
        &lt;span&gt;Serial Number&lt;/span&gt;
        &lt;p-inputMask mask="a*-999-a999" [(ngModel)]="val6" placeholder="a*-999-a999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
&lt;/div&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class InputMaskDemo &#123;

    val1: string;

    val2: string;

    val3: string;

    val4: string;

    val5: string;
    
    val6: string;
    
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-inputmask-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>